package cn.waqwb.util;

import java.sql.*;

public class DBUtil {
	static {
		try {
			Class.forName("com.mysql.jdbc.Driver");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	public static Connection getConnection() {
		Connection con = null;
		try {
			String url = "jdbc:mysql://localhost:3306/dang?useUnicode&characterEncoding=utf8&serverTimezone=UTC";
			con = DriverManager.getConnection(url, "waqwb", "qiu55555");
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return con;
	}

	public static void close(ResultSet rs, PreparedStatement prep,
			Connection con) {
		try {
			if (rs != null) {
				rs.close();
			}
			if (prep != null) {
				prep.close();
			}
			if (con != null) {
				con.close();
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
